#include "head.hpp"
#include <time.h>

void* productor(void* argv)
{
  RingQueue<int>* rq = (RingQueue<int>*)(argv);

  while(true)
  {
    int i = rand() % 20;

    rq->push(i);
    sleep(1);
  }
  return NULL;
}

void* consumer(void* argv)
{
  RingQueue<int>* rq = (RingQueue<int>*)(argv);

  while(true)
  {
    int i = rq->pop();

    (void)i;
  }
  return NULL;
}

int main()
{
  srand((unsigned int)time(nullptr));
  pthread_t t1,t2;

  RingQueue<int> rq;
  pthread_create(&t1, nullptr, productor, &rq);
  pthread_create(&t2, nullptr, consumer, &rq);

  pthread_join(t1,NULL);
  pthread_join(t2,NULL);

  return 0;
}
